package com.chat.websocket.config;

import io.minio.MinioClient;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 孙敬佳
 * 2023 \ 12 \ 08
 */

@Data
@Configuration
@ConfigurationProperties(prefix = "minio")
public class MinIOConfig {

	/**
	 * Minio 服务端 api地址
	 */
	private String url;

	/**
	 * 连接账号
	 */
	private String accessKey;

	/**
	 * 连接秘钥
	 */
	private String secretKey;

	/**
	 * minio存储桶的名称
	 */
	private String bucketName;

	/**
	 * 构建 操作Minio的客户端
	 * @return
	 */
	@Bean
	public MinioClient minioClient() {
		return MinioClient.builder()
				.endpoint(url)
				.credentials(accessKey, secretKey)
				.build();
	}
}
